package reflect;

/**
 * 使用反射机制实例化对象
 */
public class ReflectDemo2 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        //1获取对应的类对象
        Class cla = Class.forName("reflect.Person");
        //2通过类对象的newInstance()方法调用该类的无参构造器实例化
        Object obj = cla.newInstance();//new Person();
        System.out.println(obj);
    }
}
